var temp = {
    type0: function (id, data, fn, i) {//id,数据,返回函数，索引
        // $(".as-item").width($('.panel-head').width())
        $(id).append(`<div class="as-item">
		              <div class="as-item-tit" >${data.name}</div>
		              <div class="as-item-con" style="height: 51px;padding-right: 20px;">
		                <ul class="check-group check-radio" id="${data.stringId}" indexs="${i}" >
		                ${fn}
		                  
		                </ul>
		              
		              </div>
		            </div>`)
        // fn.length>800?$("#"+data.stringId).parent().append(`<a class="more" href="javascript:void(0)"><i class="icon-add-circle-o"></i>更多</a>`) : '';
        //$("#"+data.stringId).height()
        console.log($("#" + data.stringId).height())
        $("#" + data.stringId).height() > 41 ? $("#" + data.stringId).parent().append(`<a class="more" href="javascript:void(0)"><i class="icon-add-circle-o"></i>更多</a>`) : '';
        /* if($("#"+data.stringId).height()>51){
         $("#"+data.stringId).parent().append(`<a class="more" href="javascript:void(0)"><i class="icon-add-circle-o"></i>更多</a>`)

         }*/
        //  console.log($("#"+data.stringId).height())
        $(".as-item").off('click').on("click", ".more", function () {
            $(this).parent().height() < 51 ? $(this).parent().css({"height": "auto"}) : $(this).parent().css({"height": "50"});
        })
    },
    setInitTime: function () {//设置时间快速设置
        var tData = new Date()
        var myHour = tData.getHours();       //获取当前小时数(0-23)
        var myMin = tData.getMinutes();
        if (myHour < 10) {
            myHour = "0" + myHour;
        }
        if (myMin < 10) {
            myMin = "0" + myMin;
        }
        var myTime = ' ' + myHour + ":" + myMin;
        var myMonth = tData.getMonth() + 1;
        if (myMonth < 10) {
            myMonth = "0" + myMonth;
        }
        var myDate = tData.getDate();
        if (myDate < 10) {
            myDate = "0" + myDate;
        }
        var val = tData.getFullYear() + '-' + myMonth + '-' + myDate + ' 00:00' + '-' + tData.getFullYear() + '-' + myMonth + '-' + myDate + myTime

        $("#DateRange").val(val)//页面通用id，时间插件设置初始值
        $("#DateRange_2").val(val)
    },
    type1: function (id, data, fn) {//复杂下拉框的，渲染
        $(id).append(`<div class="as-item">
              <div class="as-item-tit">${data.name}</div>
              <div class="as-item-con">
               <select id="${data.value.stringId}">
                ${fn}
              </select>
              <span id="${data.inputs.stringId}">${data.inputs.back}：<input type="text" class="short"> ~ <input type="text" class="short"></span>
            </div>
          </div>`)
    },
    logTitleArr: function () {//头部标志索引
        var leftName = ['Hbase访问日志', 'Solr访问日志', 'MySQL访问日志', 'MongoDB访问日志', 'FTP采集日志', '数据库静态脱敏 - Hbase',
            '数据库静态脱敏 - Solr', '数据库静态脱敏 - MySQL', '数据库动态脱敏 - MySQL', '文件静态脱敏', '文件动态脱敏',
            '运维操作日志',
            '监管平台日志', '探针设备日志', '脱敏设备日志', '运维设备日志'];
        return leftName;
    },
    atm: function (data, num) {//table表的渲染

        function actResult(val) {
            var td2 = ['成功', '失败']
            var str = '';
            if (td2.indexOf(val) == 0) {
                str += '<span class="badge badge-success">' + val + '</span>'
            }
            else if (td2.indexOf(val) == 1) {
                str += '<span class="badge badge-danger">' + val + '</span>'
            }
            return str;
        }

        function aryys(datas) {
            var str = '<div class="sqltxt">';
        /*    for (var i = 0; i < datas.length; i++) {
                if(i==0){
                    str +=datas[i]
                }else {
                    str += ":"+ datas[i]
                }
            }*/
            str+=datas
            str += `</div>`
            return str

        }

        function deseDjArrs(detailArr) {
            var tdLen = 1;
            var fStr = "";
            if (detailArr != null) {
                tdLen = detailArr.length + 1;
                for (var i = 0; i < detailArr.length; i++) {
                    var det = detailArr[i];
                    fStr += "<tr> <td class='tdtit'>" + det.field + "</td>";
                    fStr += "<td colspan='3'>" + det.deseName + "</td> </tr>";
                }
            }
            var str = "<tr> <td rowspan='" + tdLen + "' class='tdgroup'>字段信息</td><td class='tdtit'>字段</td> <td colspan='3'>敏感类型[脱敏算法名]</td> </tr>";
            str += fStr;
            return str
        }

        function deseWJArrs(detailArr) {
            var tdLen = 1;
            var fStr = "";
            if (detailArr != null) {
                tdLen = detailArr.length + 1;
                for (var i = 0; i < detailArr.length; i++) {
                    var det = detailArr[i];
                    fStr += "<tr> <td class='tdtit'>" + det.field + "</td>";
                    fStr += "<td colspan='3'>" + det.deseName + "</td> </tr>";
                }
            }
            var str = "<tr> <td rowspan='" + tdLen + "' class='tdgroup'>脱敏类型</td><td class='tdtit'>字段</td> <td colspan='3'>脱敏算法名</td> </tr>";
            str += fStr;
            return str
        }

        //根据上面的索引，判断页面当前的弹框，应该选择怎样的模板字符串，参照‘leftName’
        if (num == 0 || num == 1 || num == 2 || num == 3 || num == 4) {//如： 'Hbase访问日志','Solr访问日志','MySQL访问日志','MongoDB访问日志','FTP采集日志',
            var str = `<tr>
            <td class="tdtit">日志来源</td>
            <td>${data.REPT_DEVICE_NUM}</td>
            <td class="tdtit">操作时间</td>
            <td>${data.TIME}</td>
          </tr>
          <tr>
            <td class="tdtit">风险等级</td>
            <td>${data.LEVEL}</td>
            <td class="tdtit">ID</td>
            <td>${data.ID}</td>
          </tr>
          <tr>
            <td class="tdtit">会话ID</td>
            <td>${data.SES_ID}</td>
            <td class="tdtit">数据库连接帐号</td>
            <td>${data.USR}</td>
          </tr>
          <tr>
            <td class="tdtit">客户端IP</td>
            <td>${data.CLIENT_IP}</td>
            <td class="tdtit">客户端端口</td>
            <td>${data.CLIENT_PORT}</td>
          </tr>
          <tr>
            <td class="tdtit">客户端MAC地址</td>
            <td>${data.CLIENT_MAC}</td>
            <td class="tdtit">客户端系统帐号</td>
            <td>${data.USR}</td>
          </tr>
          <tr>
            <td class="tdtit">客户端系统主机名</td>
            <td>${data.CLIENT_HOST}</td>
            <td class="tdtit">客户端工具</td>
            <td>${data.DATA_SRC}</td>
          </tr>
          <tr>
            <td class="tdtit">资源</td>
            <td>${data.RESRC_ID}</td>
            <td class="tdtit">数据库名称</td>
            <td>${data.DB_NAME}</td>
          </tr>
          <tr>
            <td class="tdtit">数据库类型</td>
            <td>${data.DB_VERS}</td>
            <td class="tdtit">服务器MAC地址</td>
            <td>${data.SERVER_MAC}</td>
          </tr>
          <tr>
            <td class="tdtit">服务器IP</td>
            <td>${data.SERVER_IP}</td>
            <td class="tdtit">服务器端口</td>
            <td>${data.SERVER_PORT}</td>
          </tr>
          <tr>
            <td class="tdtit">表名</td>
            <td>${data.TBL_NAME}</td>
            <td class="tdtit">操作类型</td>
            <td>${data.OPER_TYPE}</td>
          </tr>
          <tr>
            <td class="tdtit">操作语句</td>
            <td colspan="3"><div  class="sqltxt">${data.OPER_SENT}</div></td>
          </tr>
          <tr>
            <td class="tdtit">执行结果</td>
            <td>${actResult(data.ACT_RESULT)}</td>
            <td class="tdtit">返回记录</td>
            <td>${data.ROW_NUM}</td>
          </tr>
          <tr>
            <td class="tdtit">返回结果</td>
            <td colspan="3">${aryys(data.RETU_CONT)}</td>
          </tr>`;
            return str
        }
        else if (num == 5 || num == 6 || num == 7) {
            function aryys(datas) {
                var str = '';
                for (var i = 0; i < datas.length; i++) {
                    str += "<span class='badge'>" + datas[i] + "</span>"
                }
                return str

            }

            var str = `<tr><td rowspan="2" class="tdgroup">基本信息</td>
              <td class="tdtit">脱敏任务ID</td>
           <td>${data.TASK_ID}</td>
           <td class="tdtit">脱敏时间</td>
           <td>${data.TASK_TM}</td> </tr>
           <tr> <td class="tdtit">脱敏行数</td>
               <td>${data.DESE_NUM_ROW}</td>
              <td class="tdtit">脱敏结果</td>
              <td>${actResult(data.ACT_RESULT)}</td> </tr>
            <tr><td rowspan="3" class="tdgroup">源数据信息</td>
               <td class="tdtit">源数据名称</td>
          <td colspan="3">${data.SRC_NAME}</td> </tr>
               <tr> <td class="tdtit">源数据库名称</td>
          <td>${data.SRC_DB_NAME}</td>
          <td>源数据库类型</td>
           <td>${data.SRC_TYPE}</td></tr>
               <tr> <td class="tdtit">数据库IP</td>
               <td>${data.SRC_ADDR}</td>
          <td>源表名称</td>
          <td>${data.SRC_TAB_NAME}</td></tr>
          <tr><td rowspan="3" class="tdgroup">目标数据信息</td>
          <td class="tdtit">目标数据名称</td>
          <td colspan="3">${data.DEST_NAME}</td> </tr>
          <tr> <td class="tdtit">目标数据库名称</td>
           <td>${data.DEST_DB_NAME}</td>
          <td>目标数据库类型</td>
           <td>${data.DEST_TYPE}</td> </tr>
          <tr> <td class="tdtit">目标数据库IP</td>
          <td>${data.DEST_ADDR}</td>
           <td>目标表名称</td>
          <td>${data.DEST_TAB_NAME}</td> </tr> ${deseDjArrs(data.DESE_DETAIL)}`;

            return str

        }
        //数据库动态脱敏mysql
        else if (num == 10) {
            var str = `<tr><td rowspan="2" class="tdgroup">基本信息</td>
                <td class="tdtit">脱敏任务ID</td>
                <td>${data.TASK_ID}</td>
                <td class="tdtit">脱敏时间</td>
                <td>${data.TASK_TM}</td> </tr>
            <tr> <td class="tdtit">脱敏行数</td>
                <td>${data.DESE_NUM_ROW}</td>
                <td class="tdtit">脱敏结果</td>
                <td>${actResult(data.ACT_RESULT)}</td> </tr>
            <tr><td rowspan="3" class="tdgroup">源数据信息</td>
                <td class="tdtit">源数据名称</td>
                <td colspan="3">${data.SRC_NAME}</td> </tr>
            <tr> <td class="tdtit">源数据库名称</td>
                <td>${data.SRC_DB_NAME}</td>
                <td>源数据库类型</td>
                <td>${data.SRC_TYPE}</td></tr>
            <tr> <td class="tdtit">数据库IP</td>
                <td>${data.SRC_ADDR}</td>
                <td>源表名称</td>
                <td>${data.SRC_TAB_NAME}</td></tr> ${deseDjArrs(data.DESE_DETAIL)}`;

            return str
        }
        //文件静态脱敏
        else if (num == 8) {
            var str = `<tr><td rowspan="2" class="tdgroup">基本信息</td>
                <td class="tdtit">脱敏任务ID</td>
                <td>${data.TASK_ID}</td>
                <td class="tdtit">脱敏时间</td>
                <td>${data.TASK_TM}</td> </tr>
            <tr> <td class="tdtit">脱敏行数</td>
                <td>${data.DESE_NUM_ROW}</td>
                <td class="tdtit">脱敏结果</td>
                <td>${actResult(data.ACT_RESULT)}</td> </tr>
            <tr> <td rowspan="2" class="tdgroup">源数据信息</td>
                <td class="tdtit">源数据名称</td>
                <td>${data.SRC_NAME}</td>
                <td class="tdtit">源数据IP</td>
                <td>${data.SRC_ADDR}</td> </tr>
            <tr> <td class="tdtit">源数据路径</td>
                <td colspan="3">${data.SRC_DB_NAME}</td> </tr>
            <tr> <td rowspan="2" class="tdgroup">目标数据信息</td>
                <td class="tdtit">目标数据名称</td>
                <td>${data.DEST_NAME}</td>
                <td>目标数据IP</td>
                <td>${data.DEST_ADDR}</td></tr>
            <tr> <td class="tdtit">目标数据路径</td>
                <td colspan="3">${data.DEST_DB_NAME}</td></tr>
                 ${deseWJArrs(data.DESE_DETAIL)}`;
            return str
        }
        //文件动态脱敏
        else if (num == 9) {
            var str = `<tr><td rowspan="2" class="tdgroup">基本信息</td>
                <td class="tdtit">脱敏任务ID</td>
                <td>${data.TASK_ID}</td>
                <td class="tdtit">脱敏时间</td>
                <td>${data.TASK_TM}</td> </tr>
            <tr> <td class="tdtit">脱敏行数</td>
                <td>${data.DESE_NUM_ROW}</td>
                <td class="tdtit">脱敏结果</td>
                <td>${actResult(data.ACT_RESULT)}</td> </tr>
            <tr> <td rowspan="2" class="tdgroup">源数据信息</td>
                <td class="tdtit">源数据名称</td>
                <td>${data.SRC_NAME}</td>
                <td class="tdtit">源数据IP</td>
                <td>${data.SRC_ADDR}</td> </tr>
            <tr> <td class="tdtit">源数据路径</td>
                <td colspan="3">${data.SRC_DB_NAME}</td> </tr>
            <tr> <td class="tdgroup">脱敏用户</td>
                <td class="tdtit">用户名</td>
                <td>${data.USR}</td>
                <td class="tdtit">用户IP</td>
                <td>${data.CLIENT_IP}</td> </tr> ${deseWJArrs(data.DESE_DETAIL)}`;
            return str;
        }
    }

}